<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


    <script>
        function test1() {
            console.log('test1中的this', this); // window
        }

        window.test1();

        var obj = {
            test2: function() {
                console.log('test2中的this', this); // obj
            }
        }

        obj.test2();


        setTimeout(function() {
            console.log('setTimeout中的this', this);
        }, 1000);
    </script>
</body>

</html>